/**
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://license.openmrs.org
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */

package org.openmrs.module.datalogging.configuration;

import org.openmrs.BaseOpenmrsMetadata;
import org.openmrs.module.datalogging.enums.OffsetType;
import org.openmrs.module.datalogging.enums.VariableType;

/**
 * <p>Variable will store the configuration for any element that will get logged. The variable have a few property that can be tweaked to achieve
 * element that we want to log.</p>
 * <p/>
 * <p>
 * Every variable definition will have:
 * <ul>
 * <li> variableType: define what kind of variable will be logged (e.g. observation data, encounter, or custom data) </li>
 * <li> valueType: how the value should be rendered </li>
 * <li> filterExpression: limiting the variable that need to logged </li>
 * <li> valueExpression: define the expression to pull the value to be logged (e.g. valueNumeric of obs, patientId of patient) </li>
 * <li> offsetType: offset of counting to decide which object to log </li>
 * <li> valueOffset: the offset count from the offset type (e.g. encounter no 3 from the last encounter) </li>
 * </ul>
 * </p>
 * <p>
 * Usage example:
 * I want to log the second cd4 from the last cd4 count of patient. To achieve this, we would do variable type is obs, value type is numeric,
 * filter expression is empty, value expression is valueNumeric, offset type is last and offset value is 2.
 * </p>
 */
public class Variable extends BaseOpenmrsMetadata {

	private Integer variableId;

	private String description;

	private VariableType variableType;

	private String filterExpression;

	private String valueExpression;

	private OffsetType offsetType;

	private Integer valueOffset;

	/**
	 * @see org.openmrs.OpenmrsObject#getId()
	 */
	@Override
	public Integer getId() {
		return getVariableId();
	}

	/**
	 * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
	 */
	@Override
	public void setId(Integer id) {
		setVariableId(id);
	}

	/**
	 * Return the value of the variableId
	 *
	 * @return the variableId
	 */
	public Integer getVariableId() {
		return variableId;
	}

	/**
	 * Set the variableId with the variableId value
	 *
	 * @param variableId the variableId to set
	 */
	public void setVariableId(Integer variableId) {
		this.variableId = variableId;
	}

	/**
	 * Return the value of the name
	 *
	 * @return the name
	 */
	@Override
	public String getName() {
		return super.getName();
	}

	/**
	 * Set the name with the name value
	 *
	 * @param name the name to set
	 */
	@Override
	public void setName(String name) {
		super.setName(name);
	}

	/**
	 * Return the value of the description
	 *
	 * @return the description
	 */
	@Override
	public String getDescription() {
		return description;
	}

	/**
	 * Set the description with the description value
	 *
	 * @param description the description to set
	 */
	@Override
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Return the value of the variableType
	 *
	 * @return the variableType
	 */
	public VariableType getVariableType() {
		return variableType;
	}

	/**
	 * Set the variableType with the variableType value
	 *
	 * @param variableType the variableType to set
	 */
	public void setVariableType(VariableType variableType) {
		this.variableType = variableType;
	}

	/**
	 * Return the value of the filterExpression
	 *
	 * @return the filterExpression
	 */
	public String getFilterExpression() {
		return filterExpression;
	}

	/**
	 * Set the filterExpression with the filterExpression value
	 *
	 * @param filterExpression the filterExpression to set
	 */
	public void setFilterExpression(String filterExpression) {
		this.filterExpression = filterExpression;
	}

	/**
	 * Return the value of the valueExpression
	 *
	 * @return the valueExpression
	 */
	public String getValueExpression() {
		return valueExpression;
	}

	/**
	 * Set the valueExpression with the valueExpression value
	 *
	 * @param valueExpression the valueExpression to set
	 */
	public void setValueExpression(String valueExpression) {
		this.valueExpression = valueExpression;
	}

	/**
	 * Return the value of the offset
	 *
	 * @return the offset
	 */
	public OffsetType getOffsetType() {
		return offsetType;
	}

	/**
	 * Set the offset with the offset value
	 *
	 * @param offsetType the offsetType to set
	 */
	public void setOffsetType(OffsetType offsetType) {
		this.offsetType = offsetType;
	}

	/**
	 * Return the value of the valueOffset
	 *
	 * @return the valueOffset
	 */
	public Integer getValueOffset() {
		return valueOffset;
	}

	/**
	 * Set the valueOffset with the valueOffset value
	 *
	 * @param valueOffset the valueOffset to set
	 */
	public void setValueOffset(Integer valueOffset) {
		this.valueOffset = valueOffset;
	}

}
